package com.example.livemall.service.impl;

import com.example.livemall.dto.LzjResult;
import com.example.livemall.entity.Item;
import com.example.livemall.mapper.ItemMapper;
import com.example.livemall.service.BuytimeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 预定服务业务逻辑层
 */
@Service
public class BuytimeServiceImpl implements BuytimeService {

    @Autowired
    private ItemMapper itemMapper;

    /**
     * 根据主键查询商品，然后获取可预订时间属性
     *
     * @param id
     * @return
     */
    @Override
    public LzjResult buytime(String id) {
        Item item = itemMapper.selectItemById(id);
        if (item == null) {
            return LzjResult.error("查询失败");
        }
        LzjResult result = LzjResult.success();
        result.setTime(String.valueOf(item.getBuytime().getTime()));
        return result;
    }

}
